<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        class Queue{
            #items = [];

            enQueue(data){
                this.#items.push(data)
            }

            delQueue(){
                return this.#items.shift();
            }

            front(){
                return this.#items[0]
            }

            isEmpty(){
                return this.size()==0
            }

            size(){
                return this.#items.length;
            }

            clear(){
                this.#items = [];
            }

            toString(){
                return this.#items.join(' ');
            }
        }

        function game(arr,count){
            let queue = new Queue();
            arr.forEach(item=>queue.enQueue(item))

            while(queue.size()>1){
                for(let i = 0;i<count;i++){
                    queue.enQueue(queue.delQueue());
                }
                console.log(`${queue.delQueue()}出局了`);
            }
            console.log(`${queue.delQueue()}获胜`);
        }

        game(['a','b','c','d','e'],2)
        
    </script>
</body>
</html>